package com.example.student.Servicelmpl;

import com.example.student.Repository.GradeRepository;
import com.example.student.Service.GradeService;
import com.example.student.entity.Grade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {
    // 假设有一个GradeRepository用于数据库操作
    @Autowired
    private GradeRepository gradeRepository;

    @Override
    public List<Grade> listAll() {
        return gradeRepository.findAll();
    }

    @Override
    public List<Grade> getByCourseId(Long courseId) {
        return gradeRepository.findByCourseId(courseId);
    }

    @Override
    public void update(Grade grade) {
        gradeRepository.save(grade);
    }

    @Override
    public List<Grade> getByRange(Double minScore, Double maxScore) {
        return gradeRepository.findByScoreBetween(minScore, maxScore);
    }
}